package cn.jacksigxu.min3halla.init;

import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;

import java.util.function.Function;

public class MHBlockShapes {

    public static final VoxelShape BAD_TOUCH = Block.box(5, 0, 5, 11, 14, 11);
    public static final VoxelShape BAD_TOUCH_BIG = Block.box(3.5, 0, 3.5, 12.5, 21, 12.5);

    public static final VoxelShape CREVICE_SPIKE = Block.box(2, 0, 2, 14, 13, 14);
    public static final VoxelShape CREVICE_SPIKE_BIG = Block.box(0.5, 0, 0.5, 15.5, 13.5, 15.5);

    public static final VoxelShape ABSINTHE_NORTH = Shapes.or(
            Block.box(1.5, 0, 1.5, 8.5, 13, 8.5),
            Block.box(9.5, 0, 9.5, 14.5, 21, 14.5)
    );
    public static final VoxelShape ABSINTHE_WEST = Shapes.or(
            Block.box(1.5, 0, 7.5, 8.5, 13, 14.5),
            Block.box(9.5, 0, 1.5, 14.5, 21, 6.5)
    );
    public static final VoxelShape ABSINTHE_SOUTH = Shapes.or(
            Block.box(1.5, 0, 1.5, 6.5, 21, 6.5),
            Block.box(7.5, 0, 7.5, 14.5, 13, 14.5)
    );
    public static final VoxelShape ABSINTHE_EAST = Shapes.or(
            Block.box(1.5, 0, 9.5, 6.5, 21, 14.5),
            Block.box(7.5, 0, 1.5, 14.5, 13, 8.5)
    );
    public static final Function<BlockState, VoxelShape> ABSINTHE_SHAPE =
            state -> switch (state.getValue(HorizontalDirectionalBlock.FACING)) {
                default -> ABSINTHE_NORTH;
                case EAST -> ABSINTHE_EAST;
                case SOUTH -> ABSINTHE_SOUTH;
                case WEST -> ABSINTHE_WEST;
            };

    public static final VoxelShape RUM_NORTH = Shapes.or(
            Block.box(1, 0, 1, 7, 8, 7),
            Block.box(9, 0, 9, 15, 13, 15)
    );
    public static final VoxelShape RUM_WEST = Shapes.or(
            Block.box(1, 0, 9, 7, 8, 15),
            Block.box(9, 0, 1, 15, 13, 7)
    );
    public static final VoxelShape RUM_SOUTH = Shapes.or(
            Block.box(1, 0, 1, 7, 13, 7),
            Block.box(9, 0, 9, 15, 8, 15)
    );
    public static final VoxelShape RUM_EAST = Shapes.or(
            Block.box(1, 0, 9, 7, 13, 15),
            Block.box(9, 0, 1, 15, 8, 7)
    );
    public static final Function<BlockState, VoxelShape> RUM_SHAPE =
            state -> switch (state.getValue(HorizontalDirectionalBlock.FACING)) {
                default -> RUM_NORTH;
                case EAST -> RUM_EAST;
                case SOUTH -> RUM_SOUTH;
                case WEST -> RUM_WEST;
            };
}
